package com.projectzqjz.parttimework.adapter;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.projectzqjz.parttimework.R;
import com.projectzqjz.parttimework.entity.DailyEntity;
import com.projectzqjz.parttimework.myinterface.Part3HomeRefresh;

import java.util.List;

public class Part3HomeAdapter extends BaseQuickAdapter<DailyEntity, BaseViewHolder> {

    private Part3HomeRefresh part3HomeRefresh;

    public Part3HomeAdapter(List<DailyEntity> newsList,Part3HomeRefresh part3HomeRefresh) {
        super(R.layout.item_part3_home, newsList);
        this.part3HomeRefresh=part3HomeRefresh;
    }

    @Override
    protected void convert(BaseViewHolder helper, DailyEntity item) {
        RelativeLayout relFirst=helper.getView(R.id.rel_first);
        RelativeLayout relSeccond=helper.getView(R.id.rel_second);
        RelativeLayout relThird=helper.getView(R.id.rel_third);
        RelativeLayout relRefresh=helper.getView(R.id.rel_refresh);

        relRefresh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                part3HomeRefresh.refresh();
            }
        });


        switch (helper.getPosition()) {
            case 0://使用第一个
                ((TextView) helper.getView(R.id.title_1)).setText(item.getTitle());
                ((TextView) helper.getView(R.id.tv_money)).setText(item.getMoney());
                ((TextView) helper.getView(R.id.tv_unit)).setText(item.getUnit());
                ((TextView) helper.getView(R.id.lebel)).setText(item.getLabel());
                ((TextView) helper.getView(R.id.tv_gsName)).setText(item.getGsName());
                ((TextView) helper.getView(R.id.tv_time)).setText(item.getTime());
                relSeccond.setVisibility(View.GONE);
                relThird.setVisibility(View.GONE);
                relRefresh.setVisibility(View.GONE);
                break;
            case 1://使用第二个
                ((TextView) helper.getView(R.id.title_2)).setText(item.getTitle());
                ((TextView) helper.getView(R.id.tv_money1)).setText(item.getMoney());
                ((TextView) helper.getView(R.id.tv_unit1)).setText(item.getUnit());
                ((TextView) helper.getView(R.id.lebel1)).setText(item.getLabel());
                ((TextView) helper.getView(R.id.tv_gsName1)).setText(item.getGsName());
                ((TextView) helper.getView(R.id.tv_time1)).setText(item.getTime());
                relFirst.setVisibility(View.GONE);
                relThird.setVisibility(View.GONE);
                relRefresh.setVisibility(View.GONE);
                break;
            case 2://使用第三个
                ((TextView) helper.getView(R.id.title_3)).setText(item.getTitle());
                ((TextView) helper.getView(R.id.tv_money3)).setText(item.getMoney());
                ((TextView) helper.getView(R.id.tv_unit3)).setText(item.getUnit());
                ((TextView) helper.getView(R.id.lebel3)).setText(item.getLabel());
                ((TextView) helper.getView(R.id.tv_gsName3)).setText(item.getGsName());
                ((TextView) helper.getView(R.id.tv_time3)).setText(item.getTime());
                relFirst.setVisibility(View.GONE);
                relSeccond.setVisibility(View.GONE);
                break;
        }


    }
}
